package avicit.bdp.dcs.semistructure.dto;

import avicit.bdp.common.base.BaseDTO;
import avicit.platform6.core.annotation.log.FieldRemark;
import avicit.platform6.core.annotation.log.Id;
import avicit.platform6.core.annotation.log.LogField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.multipart.MultipartFile;

import javax.persistence.Column;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.constraints.NotEmpty;
import java.util.List;

/**
 * @金航数码科技有限责任公司
 * @作者：liyb
 * @邮箱：liyb@avic-digital.com
 * @创建时间：2023-04-03 14:09
 * @类说明：文件模板DTO
 * @修改记录：
 */
@ApiModel(value = "FileTemplateDTO", description = "bdp_dcs_file_template")
@Table(name = "bdp_dcs_file_template")
public class FileTemplateDTO extends BaseDTO {

    private static final long serialVersionUID = 1L;

    // 主键
    @Id
    @LogField
    @ApiModelProperty(value = "主键")
    @FieldRemark(column = "id", field = "id", name = "id")
    @javax.persistence.Id
    @Column(name = "id")
    private String id;

    /**
     * 数据项目Id
     */
    @LogField
    @ApiModelProperty(value = "数据项目Id")
    @FieldRemark(column = "project_id", field = "projectId", name = "数据项目Id")
    @Column(name = "project_id")
    private String projectId;

    // 模板名称
    @LogField
    @ApiModelProperty(value = "模板名称")
    @FieldRemark(column = "name", field = "name", name = "模板名称")
    @Column(name = "name")
    @NotEmpty(message = "模板名不能为空")
    private String name;

    // 模板代码
    @LogField
    @ApiModelProperty(value = "模板代码")
    @FieldRemark(column = "code", field = "code", name = "模板代码")
    @Column(name = "code")
    private String code;

    // 模板类型
    @LogField
    @ApiModelProperty(value = "模板类型，excel：4，csv：2，json:6")
    @FieldRemark(column = "type", field = "type", name = "模板类型")
    @Column(name = "type")
    private Integer type;

    // 模板状态
    @LogField
    @ApiModelProperty(value = "模板状态, 停用：0，启用：1")
    @FieldRemark(column = "status", field = "status", name = "模板状态")
    @Column(name = "status")
    private Integer status;

    // 指定数据开始行or指定数据位置
    @LogField
    @ApiModelProperty(value = "指定数据开始行or指定数据位置")
    @FieldRemark(column = "start_line", field = "startLine", name = "指定数据开始行or指定数据位置")
    @Column(name = "start_line")
    private String startLine;

    // 指定sheet页
    @LogField
    @ApiModelProperty(value = "指定sheet页")
    @FieldRemark(column = "sheet_tab", field = "sheetTab", name = "指定sheet页")
    @Column(name = "sheet_tab")
    private Integer sheetTab;

    // 分隔符
    @LogField
    @ApiModelProperty(value = "分隔符")
    @FieldRemark(column = "file_separator", field = "fileSeparator", name = "分隔符")
    @Column(name = "file_separator")
//    @Pattern(regexp = "^[, |_-]${1}", message = "分隔符长度限制一个字符，可以为英文逗号，竖线|，下划线_,横杠-，空格")
    private String fileSeparator;

    // 单双引号处理
    @LogField
    @ApiModelProperty(value = "单双引号处理")
    @FieldRemark(column = "quotation", field = "quotation", name = "单双引号处理")
    @Column(name = "quotation")
    private Integer quotation;

    // 单引号
    @LogField
    @ApiModelProperty(value = "单引号")
    @FieldRemark(column = "single_quotation", field = "singleQuotation", name = "单引号")
    @Column(name = "single_quotation")
    private String singleQuotation;

    // 双引号
    @LogField
    @ApiModelProperty(value = "双引号")
    @FieldRemark(column = "double_quotation", field = "doubleQuotation", name = "双引号")
    @Column(name = "double_quotation")
    private String doubleQuotation;

    // 描述
    @LogField
    @ApiModelProperty(value = "描述")
    @FieldRemark(column = "remark", field = "remark", name = "描述")
    @Column(name = "remark")
    private String remark;

    // 模板字段
    @ApiModelProperty(value = "模板字段")
    @Transient
    private String templateField;

    // 模板字段List
    @ApiModelProperty(value = "模板字段List")
    @Transient
    private List<TemplateFieldDTO> templateFieldList;

    // 模板类型
    @ApiModelProperty(value = "模板类型")
    @Transient
    private String typeString;

    @ApiModelProperty(value = "文件对象")
    @Transient
    private MultipartFile file;

    @ApiModelProperty(value = "是否覆盖")
    @Transient
    private boolean overwrite;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getStartLine() {
        return startLine;
    }

    public void setStartLine(String startLine) {
        this.startLine = startLine;
    }

    public String getFileSeparator() {
        return fileSeparator;
    }

    public void setFileSeparator(String fileSeparator) {
        this.fileSeparator = fileSeparator;
    }

    public Integer getQuotation() {
        return quotation;
    }

    public void setQuotation(Integer quotation) {
        this.quotation = quotation;
    }

    public String getSingleQuotation() {
        return singleQuotation;
    }

    public void setSingleQuotation(String singleQuotation) {
        this.singleQuotation = singleQuotation;
    }

    public String getDoubleQuotation() {
        return doubleQuotation;
    }

    public void setDoubleQuotation(String doubleQuotation) {
        this.doubleQuotation = doubleQuotation;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public String getTemplateField() {
        return templateField;
    }

    public void setTemplateField(String templateField) {
        this.templateField = templateField;
    }

    public MultipartFile getFile() {
        return file;
    }

    public void setFile(MultipartFile file) {
        this.file = file;
    }

    public boolean isOverwrite() {
        return overwrite;
    }

    public void setOverwrite(boolean overwrite) {
        this.overwrite = overwrite;
    }

    public Integer getSheetTab() {
        return sheetTab;
    }

    public void setSheetTab(Integer sheetTab) {
        this.sheetTab = sheetTab;
    }

    public String getProjectId() {
        return projectId;
    }

    public void setProjectId(String projectId) {
        this.projectId = projectId;
    }

    public List<TemplateFieldDTO> getTemplateFieldList() {
        return templateFieldList;
    }

    public void setTemplateFieldList(List<TemplateFieldDTO> templateFieldList) {
        this.templateFieldList = templateFieldList;
    }

    public String getTypeString() {
        return typeString;
    }

    public void setTypeString(String typeString) {
        this.typeString = typeString;
    }

    @Override
    public String getLogFormName() {
        if (StringUtils.isEmpty(super.logFormName)) {
            return "文件模板管理";
        } else {
            return super.logFormName;
        }
    }

    @Override
    public String getLogTitle() {
        if (StringUtils.isEmpty(super.logTitle)) {
            return "文件模板";
        } else {
            return super.logTitle;
        }
    }

}
